﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using entities;
using logic;

namespace GamesFormsApplication
{
    public partial class GamesForm : Form
    {
        private Hero hero = new Hero();

        private HeroLogic logic = new HeroLogic();

        public GamesForm()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

      

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void addButton_Click_1(object sender, EventArgs e)
        {
            EditForm form = new EditForm();
            form.ShowDialog();
            AbstractWeapon weapon = form.GetGun();            

            if ((weapon.Damage < 0) ||
                    (weapon.Level < 0))
            {
                MessageBox.Show("Damage and Level can not be less than zero");
            }
            else
            {
                if (weapon != null)
                {
                    this.weaponsBox.Items.Add(weapon);
                    hero.Bag.Add(weapon);
                }
                int totalDamage = logic.GetTotalDamage(hero);
                this.totalDamageLabel.Text = totalDamage.ToString();
            }
                
            
        }

        private void deleteButton_Click(object sender, EventArgs e)
        {
            AbstractWeapon selectedItem = (AbstractWeapon)weaponsBox.SelectedItem;
            List<AbstractWeapon> weapon = hero.Bag.Weapons;
            weapon.Remove(selectedItem);
            this.weaponsBox.Items.Remove(selectedItem);         

        }
        
    }
}
